package com.mxx.bu_yang.dialog;

import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.mxx.bu_yang.R;
import com.mxx.bu_yang.adapter.GoodsOwnerAdapter;
import com.mxx.bu_yang.response.GoodsOwnerResponse;

import java.util.ArrayList;
import java.util.List;

/**
 * 作者：刘江飞
 * 时间：2020/10/14  15:14
 * 邮箱：642371742Z@qq.com
 * 描述：货主
 **/
public class GoodsOwnerListDialog extends CommonListDialog<GoodsOwnerResponse> {
    public GoodsOwnerListDialog(int widgetWidth, int location_x, int widgetHeight, int location_y, boolean transparent) {
        super(widgetWidth, location_x, widgetHeight, location_y, transparent);
    }

    /**
     * Sets layout id.
     *
     * @return the layout id
     */
    @Override
    protected int setLayoutId() {
        return R.layout.dialog_warehouse_list;
    }


    @Override
    protected BaseQuickAdapter createAdapter() {
        return new GoodsOwnerAdapter(R.layout.adapter_common_drown_down);
    }

    @Override
    protected void loadServerData() {
        List<GoodsOwnerResponse> list = new ArrayList<>();
        for (int i = 0; i < 9; i++) {
            GoodsOwnerResponse response = new GoodsOwnerResponse();
            response.name = "张三" + i + 1;
            list.add(response);
        }
        ((GoodsOwnerAdapter) mAdapter).setList(list);
    }

    @Override
    public void onItemChildClick(@NonNull BaseQuickAdapter adapter, @NonNull View view, int position) {
        if (view.getId() == R.id.tv_name) {
            if (backDataListener == null) {
                return;
            }
            dismiss();
            backDataListener.backData((GoodsOwnerResponse) adapter.getItem(position));
        }
    }
}
